package game.manager;

import game.Constants;
import game.Event;
import game.Person;

import java.util.Observable;

public class EnergyManager implements Manager {
	private static EnergyManager manager;

	public static EnergyManager getManager() {
		if (manager == null)
			manager = new EnergyManager();
		return manager;
	}

	@Override
	public void update(Observable o, Object arg) {
		final Event event = (Event) arg;

		switch (event.getType()) {
		case RESET:
			this.initialize();
			break;
		case GAME_STARTED:
			break;
		case MINUTE_PASSED:
			Person user = PersonManager.getManager().getUser();
			int energy = user.getEnergy();

			int newEnergy = Math.min(Constants.ENERGY_MAX, energy
					+ Constants.ENERGY_MINUTE_REGEN);
			user.setEnergy(newEnergy);
			break;
		}
	}

	@Override
	public void initialize() {
	}

	@Override
	public void gameUpdate() {

	}
}
